home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-2.iso / Files II / Prog / U-Z / ViewIt 2.24 Shareware.sit / ViewIt™ 2.24 Shareware / FaceWare.rsrc / TEXT_1269_C1. Introduction.txt < prev    next >
Encoding:
Text File  |  1994-04-10  |  4.3 KB  |  50 lines

  1. C1. FaceIt & ViewIt Commands
  2.  
  3.   As described in the "Startup" topics, communication between a program and FaceWare modules is accomplished via the global fRec record and the "FaceIt" dispatching procedure.  The fRec record is described in the "fRec Record" topic, and commands supported by FaceIt and ViewIt that can be passed to the FaceIt dipatching procedure are described in the other topics under the "Commands" menu.
  4.  
  5. Command Format
  6.   The FaceIt dispatching procedure is found in the "FaceProcXY" file (or in some other form compatible with your programming environment).  Calls to this procedure always have the form,
  7.   FaceIt(nil,[command],a,b,c,d);   {Pascal}
  8.   FaceIt(0,[command],a,b,c,d);     /* C, C++ */
  9.   call FaceIt(0,[command],a,b,c,d) !FORTRAN
  10. where parameters a, b, c, and d are 4-byte integers, and where other record elements from the global fRec or other records may be used with particular commands.
  11.   Each FaceIt and ViewIt command name, its equivalent number, the parameters and record elements used by the command, and a complete description of the command are presented in the topics under the "Commands" menu.  Command names can be used in place of the numbers in calls to the FaceIt procedure since they are declared as constants in the "FaceStorXY" file (or in some other way compatible with your programming environment).
  12.  
  13. Command Types
  14.   The commands described under the "Commands" menu are of 3 general types:
  15.   1. "Program Commands" are commands supported by the FaceIt module that deal with program-wide features (the main loop, the main menu bar, modeless window management, etc.).
  16.   2. "Window" and "Control Commands" are commands supported by the ViewIt module that deal directly with ViewIt windows and controls.
  17.   3. The "Utilities" commands are also supported by ViewIt, but provide a wide range of utility-type routines that augment the Macintosh toolbox.  These utility routines are used internally by ViewIt and control drivers, but can also be called by your program for its own purposes.
  18.  
  19. Clobbered Variables
  20.   Most fRec variables are scratch variables that can be changed by any call to the FaceIt dispatching procedure or to the Control Manager (since the Control Manager then calls ViewIt via CDEF 1200).  The scratch variables include all those prefixed by the letters "u", "w", or "c".  This means that you cannot rely on the content of these fRec variables across calls to FaceIt or the Control Manager.  The rule of thumb to follow is that if you will be using such an fRec variable in more than one FaceIt or Control Manager call, then save a copy of its contents in a local variable and use the copy.  The major exception to this rule is that most utility-type routines preserve the content of the "w" and "c" variables since they do not deal directly with ViewIt windows.
  21.   Suppose, for example, that a control handle is needed for use in a single call to "SizeControl".  In this case you can get away with using the cControl returned by GetCtl:
  22.  FaceIt(nil,GetCtl,1030,0,1,5);
  23.  SizeControl(fRec.cControl,100,100);
  24. But if the control handle is also used in a subsequent call, then a copy of cControl should be used:
  25.  FaceIt(nil,GetCtl,1030,0,1,5);
  26.  theControl := fRec.cControl;
  27.  SizeControl(theControl,100,100);
  28.  FaceIt(nil,AddCtl,1004,0,ord(theControl),0);
  29. since both the Control Manager and FaceIt calls can result in clobbering the current values in fRec.
  30.   The same precaution should be taken with commonly used variables such as uString, uMenuID, uMenuItem, wvHit, wcHit, and wiHit, although these are most often used as simple case selectors in case blocks in a way that does not require their contents to be saved.  The following code, for example, is safe since it makes just one use of uMenuID between calls to DoLoop:
  31.  repeat
  32.   FaceIt(nil,DoLoop,0,0,0,0);
  33.   if (uMenuID = 1001) then
  34.    ...
  35.   else if (uMenuID = 1002) then
  36.    ...
  37.   else if (uMenuID = 1003) then
  38.    ...
  39.  until false;
  40. but the similar code that follows is asking for trouble since it assumes that the actions taken after each "if...then" do not affect the contents of uMenuID:
  41.  repeat
  42.   FaceIt(nil,DoLoop,0,0,0,0);
  43.   if (uMenuID = 1001) then
  44.    ...
  45.   if (uMenuID = 1002) then
  46.    ...
  47.   if (uMenuID = 1003) then
  48.    ...
  49.  until false;
  50. This code could also be fixed by simply storing the contents of uMenuID in a local variable and using that variable in the "if...then" blocks.